﻿<%@ page language="java" import="com.ruohi.util.common.CommonForm,com.ruohi.util.common.CommonString"
         pageEncoding="UTF-8" %>
<%@ page import="com.ruohi.util.common.Env" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%
	Map brandMap = (Map)application.getAttribute("giftBrandMap");
	String tableName = "gift_information";
	String tablePrefix = Env.getInstance().getProperty("table_prefix");
	String fileds = "id,uuid,title,brand,pub_date,is_show,view_count";
	String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
	String whereStr = " ";
	String orderByStr = " pub_date desc ";
	Map isMap = new HashMap();
	isMap.put("","-请选择-");
	isMap.put("1","是");
	isMap.put("0","否");
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><%=Env.getInstance().getProperty("project_name") %></title>
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
	<link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<link href="/backend/style/style.css" rel="stylesheet" type="text/css" />
	<script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
  </head>
  <body>
  	<div class="searchForm">
  		<div class="searchCondition">
  			<div class="searchList">
		  		<div class="searchLeft">标题</div>
		  		<div class="searchRight">
		  			<input type="text" class="jr_text" name="title" id="title" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		<div class="searchLeft">起始日期</div>
		  		<div class="searchRight">
		  			<input type="text" class="Wdate jr_text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="start_date" id="start_date" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		 <div class="searchLeft">结束日期</div>
		  		<div class="searchRight">
		  			<input type="text" class="Wdate jr_text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" name="end_date" id="end_date" />
		  		</div>
		  	</div>
		  	<div class="searchList">
		  		<div class="searchLeft">是否发布</div>
		  		<div class="searchRight">
		  			<select name="is_show" id="is_show" class="jr_select">
		  				<%=CommonForm.createSelect(isMap,"") %>
		  			</select>
		  		</div>
		  	</div>
  		</div>
  		<div class="searchBtn">
  			<input type="button" class="btn" onclick="doSearch();" value="查询" /><input type="button" style="margin-left: 5px;" class="btn" onclick="doClearForm();" value="重置" />
  		</div>
  	</div>
  	<div style="clear: left;"></div>
  	
	<div class="l-loading" style="display: block" id="pageloading"></div> 
	<div id="maingrid" style="margin: 0; padding: 0"></div>
	<div style="display: none;"></div>
  </body>
</html>
<script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="/plugin/date/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="/backend/scripts/common.js" prefix="<%=tablePrefix %>" type="text/javascript"></script>
<script type="text/javascript">
	var grid;
	var windowWidth = 800;
	var windowHeight = 420;
	var channelUUID = '<%=channelUUID %>';
	var tableName = "<%=tableName %>";
	var fields = "<%=fileds %>";
	var whereStr = "<%=whereStr %>";
	var orderBy = "<%=orderByStr %>";
	var columnsArr = [];
	var url = "";
	var conditionStr = "";
	var params = [];
	jQuery(function() {
		params.push({'name':'enumNo','value':'106013'});
		grid = new Dev21sunGrid();
		jQuery("#pageloading").hide();
	});
	var is_showData = [{ is_show : 1 , text: '是' }, { is_show : 0 , text: '否'}];
	//列数组
	columnsArr =  [ 
		{ display : '标题', name : 'title', align : 'left' , type : 'string' , width : 500 , render : function(row){
				return "<img onclick='doPreview(\""+row.id+"\");' class='preview' src='/plugin/ui/ligerUI/ligerUI/skins/icons/preview.png' /><a class='link' href='javascript:void(0);' onclick='addAndEdit("+row.__index+");'>"+row.title+"</a>";
			}
		} ,
		{ display : '发布日期', name : 'pub_date', align : 'center' , type : 'date' , width : 100 } ,
	{ display : '是否发布', name : 'is_show', align : 'center' , type : 'is' , width : 80 ,
		editor: { 
			type: 'select', 
			data: is_showData, 
			valueColumnName: 'is_show' 
		},
		render : function(row){
			var is_show = row.is_show;
			if(is_show==1){
				is_show="是";
			}else{
				is_show = "<span style='color:red;'>否</span>";
			}
			return is_show;
		}
	 } ,
		{ display : '点击次数', name : 'view_count', align : 'right' , type : 'int' , width : 80 } 
	];
	
	function doPreview(id){
        window.open('http://www.52sdskj.com/news/' + id + '.htm');
	}
	
	/*列表页条件查询*/
	function doSearch(){
		params = [];
		conditionStr = "";
		var title = jQuery("#title").val();
		if(''!=jQuery.trim(title)){
			conditionStr += " and title like '%"+title+"%' ";
		}
		var start_date = jQuery("#start_date").val();
		if(''!=jQuery.trim(start_date)){
			conditionStr += " and pub_date > '"+start_date+"' ";
		}
		var end_date = jQuery("#end_date").val() ;
		if(''!=jQuery.trim(end_date))
		{
		    conditionStr += " and pub_date < '"+end_date+"'" ;
		}
		var is_show = jQuery("#is_show").val();
		if(''!=jQuery.trim(is_show)){
			conditionStr += " and is_show = '"+is_show+"' ";
		}
		params.push({'name':'enumNo','value':'106013'});
		params.push({'name':'tableName','value':tableName});
		params.push({'name':'fileds','value':fields});
		params.push({'name':'whereStr','value':whereStr+conditionStr});
		params.push({'name':'orderBy','value':orderBy});
		grid.options.parms=params;
		grid.loadData();
	}
	
	function addAndEdit(index){
		if(undefined==index){//如果是增加
			toolbarAdd({
				width:800,
				height:500,
				title:"增加",
				params : {
	    			channel_uuid : "<%=channelUUID %>"
	    		}
			});
		}else{//如果是修改
	    	var row = grid.getRow(index);
	    	toolbarAdd({width:800,height:500,title:'编辑'},row.uuid);
		}
    }
</script>